package com.ruoyi.trans.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.trans.domain.LesseeInfo;
import com.ruoyi.trans.service.ILesseeInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 承租人信息Controller
 * 
 * @author zhangjun
 * @date 2025-05-18
 */
@RestController
@RequestMapping("/trans/lesseeInfo")
public class LesseeInfoController extends BaseController
{
    @Autowired
    private ILesseeInfoService lesseeInfoService;

    /**
     * 查询承租人信息列表
     */
    @PreAuthorize("@ss.hasPermi('trans:lesseeInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(LesseeInfo lesseeInfo)
    {
        startPage();
        List<LesseeInfo> list = lesseeInfoService.selectLesseeInfoList(lesseeInfo);
        return getDataTable(list);
    }

    /**
     * 导出承租人信息列表
     */
    @PreAuthorize("@ss.hasPermi('trans:lesseeInfo:export')")
    @Log(title = "承租人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LesseeInfo lesseeInfo)
    {
        List<LesseeInfo> list = lesseeInfoService.selectLesseeInfoList(lesseeInfo);
        ExcelUtil<LesseeInfo> util = new ExcelUtil<LesseeInfo>(LesseeInfo.class);
        util.exportExcel(response, list, "承租人信息数据");
    }

    /**
     * 获取承租人信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('trans:lesseeInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(lesseeInfoService.selectLesseeInfoById(id));
    }

    /**
     * 新增承租人信息
     */
    @PreAuthorize("@ss.hasPermi('trans:lesseeInfo:add')")
    @Log(title = "承租人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LesseeInfo lesseeInfo)
    {
        return toAjax(lesseeInfoService.insertLesseeInfo(lesseeInfo));
    }

    /**
     * 修改承租人信息
     */
    @PreAuthorize("@ss.hasPermi('trans:lesseeInfo:edit')")
    @Log(title = "承租人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LesseeInfo lesseeInfo)
    {
        return toAjax(lesseeInfoService.updateLesseeInfo(lesseeInfo));
    }

    /**
     * 删除承租人信息
     */
    @PreAuthorize("@ss.hasPermi('trans:lesseeInfo:remove')")
    @Log(title = "承租人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(lesseeInfoService.deleteLesseeInfoByIds(ids));
    }
}
